package com.example.securitydemo.password;

import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @Package: com.example.securitydemo.password
 * @ClassName: PasswordEncode
 * @Author: Think
 * @CreateTime: 2021/7/29 17:24
 * @Description:
 */
@Slf4j
public class PasswordEncode {

    private PasswordEncoder passwordEncoder;

    @Before
    public void before(){
        this.passwordEncoder = new BCryptPasswordEncoder();
    }

    @Test
    public void encodePassword(){
        String rawPassword = "root999";
        String encodePassword = passwordEncoder.encode(rawPassword);
        log.info("password:{} encoded is: {}", rawPassword, encodePassword);
    }

}
